﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace DNA.Mvc
{
    /// <summary>
    /// The Permission object.
    /// </summary>
    [Table("dna_Permissions")]
    public class Permission
    {
        /// <summary>
        /// Gets/Sets the permission id.
        /// </summary>
        [Key]
        [Column("ID", Order = 1)]
        public int ID { get; set; }

        /// <summary>
        /// Gets/Sets the permission title.
        /// </summary>
       [StringLength(255)]
        public string Title { get; set; }

        /// <summary>
        /// Gets/Sets the Action name that controlling by Permission.
        /// </summary>
        [StringLength(255)]
        public string Action { get; set; }

        /// <summary>
        /// Gets/Sets the assembly name of the controller class 
        /// </summary>
        [StringLength(1024)]
        public string Assembly { get; set; }

        /// <summary>
        /// Gets/Sets the controller name that contains the Action.
        /// </summary>
        [StringLength(255)]
        public string Controller { get; set; }

        /// <summary>
        /// Gets/Sets the permission description
        /// </summary>
        [Column(TypeName="ntext")]
        public string Description { get; set; }

        public int PermissionSetID { get; set; }

        /// <summary>
        /// Gets/Sets the permissionSet 
        /// </summary>
        [ForeignKey("PermissionSetID")]
        public virtual PermissionSet PermissionSet { get; set; }

        /// <summary>
        /// Gets/Sets the Role names that has this Permission
        /// </summary>
        public virtual ICollection<PermissionRole> Roles { get; set; }
    }
}
